package com.lineage.server.command.executor;

import com.lineage.server.datatables.lock.ClanReading;
import com.lineage.server.model.Instance.L1PcInstance;
import com.lineage.server.model.L1Clan;
import com.lineage.server.serverpackets.S_GreenMessage;
import com.lineage.server.serverpackets.S_ServerMessage;
import com.lineage.server.serverpackets.ServerBasePacket;
import com.lineage.server.world.World;
import com.lineage.server.world.WorldClan;
import java.util.Collection;

public class L1ReTakeCastle implements L1CommandExecutor {
  public static L1CommandExecutor getInstance() {
    return new L1ReTakeCastle();
  }
  
  public void execute(L1PcInstance pc, String cmdName, String arg) {
    try {
      Collection<L1Clan> clan = WorldClan.get().getAllClans();
      for (L1Clan c : clan) {
        c.setCastleId(0);
        ClanReading.get().updateClan(c);
      } 
      String SystemMsg = "系统公告：城堡已被收回";
      World.get().broadcastPacketToAll((ServerBasePacket)new S_GreenMessage("系统公告：城堡已被收回"));
      pc.sendPackets((ServerBasePacket)new S_ServerMessage(166, "系统已成功收回城堡，目前为空城"));
    } catch (Exception exception) {}
  }
}
